package com.zbc.mapper;

import com.github.pagehelper.Page;
import com.zbc.annotation.AutoFill;
import com.zbc.dto.CategoryDTO;
import com.zbc.dto.CategoryPageDTO;
import com.zbc.entity.Category;
import com.zbc.enumeration.OperationType;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface CategoryMapper {
    Page<Category> selectPageList(CategoryPageDTO categoryPageDTO);

    @AutoFill(OperationType.UPDATE)
    void update(Category category);

    @AutoFill(OperationType.INSERT)
    @Insert("Insert Into category(type,name,sort,status,create_time,update_time,create_user,update_user)" +
            "values (#{type},#{name},#{sort},#{status},#{createTime},#{updateTime},#{createUser},#{updateUser})")
    void insert(Category category);

    @Delete("delete from category where id = #{id}")
    void delete(Integer id);

    @Select("select * from category where type = #{type}")
    Category[] fetchTypeList(Integer type);
}
